package com.example.mybaseapp.ui

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.recyclerview.widget.RecyclerView
import com.example.lib_base.BaseRecyclerviewAdapter
import com.example.mybaseapp.R
import com.example.mybaseapp.databinding.ItemPackReceiverBinding

class BaseRecyclerViewAdapterTestActivity : AppCompatActivity() {
    private val dataList = arrayListOf(
        "测试1",
        "测试2",
        "测试3",
        "测试4",
        "测试5",
        "测试6",
        "测试7",
        "测试8",
        "测试9",
        "测试10",
        "测试11",
        "测试12",
    )
    private val mAdatpter= object : BaseRecyclerviewAdapter<String,ItemPackReceiverBinding>(
        dataList,R.layout.item_pack_receiver
    ){
        override fun createViewHolder(view: ItemPackReceiverBinding): BaseViewHolder<ItemPackReceiverBinding, String> {
            return object : BaseViewHolder<ItemPackReceiverBinding, String>(view) {
                override fun bind(item: String, position: Int) {
                    view.txContent.text = item
                }
            }
        }
    }
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_base_recycler_view_adapter_test)
        initView()
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
    }

    private fun initView() {
        findViewById<RecyclerView>(R.id.recyclerview).apply {
            adapter = mAdatpter
        }
    }
}